# coding=utf-8
# !/usr/bin/python3


import time
import traceback

import People
import Student

def main():
    print("hello py")

    # 循环 list
    list1 = ['tom', 'jim', 'lilei', 'rose']
    print('len=>', len(list1))
    for item in list1:
        print(item)

    # dict
    color_dict = {1: 'red', 2: 'black', 3: 'write'}
    print('1=>', color_dict[1])
    print('2=>', color_dict[2])
    print('3=>', color_dict[3])

    color_dict[1] = 'bule'  # update
    del color_dict[3]  # remove element

    for key in color_dict:
        print('key=>', key, 'values=>', color_dict[key])

    for value in color_dict.values():
        print('values=>', value)

    # time
    print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))


    #面向对象
    p = People.people('py', 10, 30)
    p.speak()

    student = Student.student();
    student.name = 'aa'
    student.age = 19
    print(student.getMessage())


    #try 异常处理
    try:
        temp = 1 / 0
        print(temp)
    except Exception as e:
        print("error: {0}".format(e))
        print(traceback.format_exc())
    finally:
        print("finally")


if __name__ == '__main__':
    main()
